import numpy as np
import matplotlib.pyplot as plt


def points_within_circle(radius, center=(0, 0), number=100):
    center_x, center_y = center
    r = radius * np.sqrt(np.random.random((number,)))
    theta = np.random.random((number,)) * 2 * np.pi
    x = center_x + r * np.cos(theta)
    y = center_y + r * np.sin(theta)
    return x, y


def generate_three_classes(cover=100, radius=40, number=100):
    class1 = np.stack(points_within_circle(radius, (radius, radius), number), 1)
    class2 = np.stack(points_within_circle(radius, (cover - radius, radius), number), 1)
    class3 = np.stack(points_within_circle(radius, (cover / 2, cover - radius), number), 1)
    return class1, class2, class3


def visualize_classes(classes):
    class1, class2, class3 = classes
    fig, ax = plt.subplots()

    x1, y1 = np.split(class1, 2, 1)
    x2, y2 = np.split(class2, 2, 1)
    x3, y3 = np.split(class3, 2, 1)
    ax.scatter(x1, y1, c="red", label="class 1")
    ax.scatter(x2, y2, c="black", label="class 2")
    ax.scatter(x3, y3, c="blue", label="class 3")

    ax.legend()
    ax.grid()
    plt.show()


if __name__ == '__main__':
    visualize_classes(generate_three_classes(radius=20))
